<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 备选字符集 -->
    <script>
        var str = "上海，上天，上到那里去";
        var reg = /上[海天]/g; //上海或者上天
        // var reg = /[上海天]/g;//上或海或天
        console.log(str.replace(reg,"$"));
    </script>

    <script>
        var a = "hello world";
        var b = /l|e/g; //遇到l或者e
        console.log(a.replace(b,"$"));
    </script>
</body>
</html>